package com.neusoft.elmboot.po;

import com.baomidou.mybatisplus.annotation.*;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.userdetails.UserDetails;

import java.io.Serializable;
import java.util.Collection;
import java.util.Date;
import java.util.List;

/**
 * 
 * 
 * @author chenshun
 * @email sunlightcs@gmail.com
 * @date 2024-02-28 11:23:16
 */
@Data
@NoArgsConstructor
@AllArgsConstructor
@Builder
@TableName("user")
public class UserEntity implements Serializable, UserDetails {
	private static final long serialVersionUID = 1L;

	@TableId(type = IdType.ASSIGN_ID)
	private Integer id;

	/**
	 * 用户编号
	 */


	private String userId;
	/**
	 * 密码
	 */
	@TableField(fill = FieldFill.INSERT,value = "password")
	private String password;
	/**
	 * 用户名称
	 */
	private String userName;
	private Integer userSex;
	private String userImg;
	private Integer del;
	private Date createTime;
	private Date updateTime;
	//实现UserDetails接口需要用到的字段：
	private boolean isexpired;
	private boolean isenable;
	private boolean islock;
	private boolean iscredentials;
	// 用户权限集合
	@TableField(exist = false)
	private List<GrantedAuthority> authorities;


	public String getUserName() {
		return this.userName;
	}

	@Override
	public String getUsername() {
		return userId;
	}

	@Override
	public boolean isAccountNonExpired() {
		return isexpired;
	}

	@Override
	public boolean isAccountNonLocked() {
		return islock;
	}

	@Override
	public boolean isCredentialsNonExpired() {
		return iscredentials;
	}

	@Override
	public boolean isEnabled() {
		return isenable;
	}
}
